package com.afalon.cloud.contracts.finance;

import java.math.BigDecimal;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

@PersistenceCapable
@XmlRootElement(name = "transactionline")
@XmlAccessorType(XmlAccessType.NONE)
public class TransactionLine 
{
	
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key transactionLineKey;
	
	@XmlElement
	@Persistent
	private BigDecimal credit;
	
	@XmlElement
	@Persistent
	private BigDecimal debit;
	
	@Persistent
    private Transaction transaction;
	
	@Persistent
	private Account account;
	
	@XmlElement
	@Persistent
	private String statementLineId;

	public TransactionLine() 
	{
		
	}

	public Key getTransactionLineKey() {
		return transactionLineKey;
	}
	
	@XmlElement
	public String getTransactionLineId() {
		return KeyFactory.keyToString(this.getTransactionLineKey());
	}

	public void setCredit(BigDecimal value) {
		credit = value;
	}

	public BigDecimal getCredit() {
		return credit;
	}

	public void setDebit(BigDecimal value) {
		debit = value;
	}

	public BigDecimal getDebit() {
		return debit;
	}

	public void setTransaction(Transaction value) {
		transaction = value;
	}

	public Transaction getTransaction() {
		return transaction;
	}

	public void setStatementLineId(String value) {
		statementLineId = value;
	}

	public String getStatementLineId() {
		return statementLineId;
	}
	
	// Foreign Fields
	
	// Parent Id
	@XmlElement
	public String getTransactionId() {
		return transaction.getTransactionId();
	}

	@XmlElement
	public String getAccountId() {
		return account.getAccountId();
	}
	
}
